export const deepCopy = (obj: any) :any => {
  if (obj instanceof Object) {
    const newObj: any = {}
    if (Array.isArray(obj)) {
      const arr: any[] = []
      obj.forEach(item => {
        arr.push(deepCopy(item))
      })
      return arr
    } else {
      for (const key in obj) {
        const value = obj[key]
        if (typeof value === 'function') {
          newObj[key] = value.bind(newObj)
        } else if (typeof value === 'object') {
          if (Array.isArray(value)) {
            newObj[key] = []
            value.forEach(item => {
              newObj[key].push(deepCopy(item))
            })
          } else {
            newObj[key] = deepCopy(value)
          }
        } else {
          newObj[key] = value
        }
      }
    }
    return newObj
  } else {
    return obj
  }
}
